cmake_minimum_required(VERSION 3.16)
project(PokemonDatasetAutoGen)
# 语言标准
set(CMAKE_CXX_STANDARD 20)
if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug)
endif()
# 编译器选项
if(MSVC)
    #utf-8支持
    add_compile_definitions("UNICODE")
    add_compile_definitions("_UNICODE")
    add_compile_options("/utf-8")
    #OpenMP 和 SIMD 支持
    add_compile_options("/openmp:experimental")
    add_compile_options("/Qvec-report:2")
    if(CMAKE_BUILD_TYPE MATCHES Debug)
    else()
        add_compile_options("/O2")
    endif()
elseif(CMAKE_COMPILER_IS_GNUCXX)
    #OpenMP支持
    add_compile_options("-fopenmp")
    #C++新语法支持
    add_compile_options("-fconcepts")
    add_compile_options("-lstdc++fs")
    #    add_compile_options("-mavx2")
    #    add_compile_options("-funsafe-math-optimizations")

    add_compile_options("-fopt-info")
    set(_CXX_FLAGS)
    if(_march_native_works)
        message(STATUS "Using processor's vector instructions (-march=native compiler flag set)")
        set(_CXX_FLAGS "-march=native")
    elseif(_xhost_works)
        message(STATUS "Using processor's vector instructions (-xHost compiler flag set)")
        set(_CXX_FLAGS "-xHost")
    else()
        message(STATUS "No suitable compiler flag found for vectorization")
    endif()
    if(CMAKE_BUILD_TYPE MATCHES Debug)
    else()
        add_compile_options("-Ofast")
    endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
    #OpenMP支持
    message("clang")
    add_compile_options("-fopenmp")
    #C++新语法支持
    add_compile_options("-fconcepts")
    add_compile_options("-lc++fs")

    add_compile_options("-fopt-info")
    set(_CXX_FLAGS)
    if(_march_native_works)
        message(STATUS "Using processor's vector instructions (-march=native compiler flag set)")
        set(_CXX_FLAGS "-march=native")
    elseif(_xhost_works)
        message(STATUS "Using processor's vector instructions (-xHost compiler flag set)")
        set(_CXX_FLAGS "-xHost")
    else()
        message(STATUS "No suitable compiler flag found for vectorization")
    endif()
    if(CMAKE_BUILD_TYPE MATCHES Debug)
    else()
        add_compile_options("-Ofast")
    endif()
else()
    error("Other compilers are not supported by this project. ")
endif()
# 输出位置
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
# 方便获得资源位置的宏定义
add_compile_definitions(CMAKE_PROJECT_DIR="${PROJECT_SOURCE_DIR}")
# 子文件夹
add_subdirectory(src/)
